#include "effect.hpp"

static const float DFRAMES[Effect::TYPECT] =
{
	.25f, .25f,
	1.f/64,	1.f/64,	1.f/64,	
	1.f/64,	1.f/64,	1.f/64
};

#include "image.hpp"
static Image *imgs[Effect::TYPECT];

bool Effect::Open()
{
	const char *STRINGS[TYPECT] =
	{
		"ehit", "ekilled",
		"ipoints", "ipointm", "ipointl", 
		"ipointxl", "ipointxxl", "ipointxxxl",
	};

	AllImgs.BatchGet(imgs, TYPECT, "effect/", STRINGS);
	return true;
}

void Effect::Close()
{
}

void Effect::Init(float x, float y, Cue & cue)
{
	typen = cue.Num();
	body = Box2f(Vec2f(-.5f, -.5f), Vec2f(1, 1));
	pos = Vec2f(x, y);
	img = imgs[typen];
	hp = 0;
}

void Effect::Update()
{
	frame += DFRAMES[typen];

	float framect = img ? img->TileCt() : 1;
	if (frame >= framect)
		Bury();
}

ActPool<Effect, Effect::COUNT> Efx;
